package com.adou.second.day10;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
/**
 * 修改student文件
 * 
 * @author admin
 *
 */
public class ObjectOutputDem2 {
	public static void main(String[] args) throws Exception {
//		write();
		
		read();
		
	}
	
	private static void write() throws Exception{
		Student stu = new Student();
		stu.setName("张三");
		stu.setChinese(98);
		stu.setMath(97);
		stu.setEnglish(100);
		
		// 序列换 文件
		ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("fos\\stu\\student3.txt"));
		oos.writeObject(stu);
		oos.close();
	}
	
	private static void read() throws Exception{
		ObjectInputStream ois = new ObjectInputStream(new FileInputStream("fos\\stu\\student2.txt"));
		Student stu2 = (Student)ois.readObject();
		System.out.println(stu2);
	}
}
